package com.cygsunri.commonutils.utils;


import com.cygsunri.commonutils.id.SnowFlakeIdWorker;

import java.util.Date;

/**
 * @author lhy
 * @since 2020/12/8 9:35
 */
public class ProcessCodeUtils {

    /**
     * 快速审核流程前缀
     */
    private static final String QUICK_CHECK_PROCESS_PREFIX = "QCP-";
    /**
     * 银行办卡流程
     */
    private static final String BANK_CARD_PROCESS_PREFIX = "BCP-";

    /**
     * 劳动维权微服务
     */
    private static final String LABOUR_MICRO_SERVICE = "LMS-";

    /**
     * 企业维权微服务
     */
    private static final String BUSINESS_MICRO_SERVICE = "BMS-";

    /**
     * 云端巡查流程前缀
     */
    private static final String CLOUD_CHECK_TASK_SERVICE = "CCT-";

    /**
     * 劳务工违纪流程前缀
     */
    private static final String ILLEGAL_PEOPLE_SERVICE = "ILL-";

    /**
     * @param type 0:快速审核流程;
     *             1:银行办卡流程;
     *             2:劳动维权微服务流程；
     *             3:企业咨询服务流程；
     *             4:云端巡查流程;
     *             5:劳务工违纪流程
     * @return 流程编号
     */
    public static String getProcessCode(int type) {
        String processCode = null;
        if (type == 0) {
            processCode = initCode(QUICK_CHECK_PROCESS_PREFIX);
        } else if (type == 1){
            processCode = initCode(BANK_CARD_PROCESS_PREFIX);
        } else if (type == 2){
            processCode = initCode(LABOUR_MICRO_SERVICE);
        } else if (type == 3){
            processCode = initCode(BUSINESS_MICRO_SERVICE);
        } else if (type == 4) {
            processCode = initCode(CLOUD_CHECK_TASK_SERVICE);
        }else if (type == 5) {
            processCode = initCode(ILLEGAL_PEOPLE_SERVICE);
        }
        return processCode;
    }

    /**
     * 初始化流程编号
     *
     * @param processType 流程编号前缀
     * @return 流程编号
     */
    private static String initCode(String processType) {
        String code = SnowFlakeIdWorker.generateNextIdStr() + "-";
        String date = SystemDateUtil.formatDate(new Date());
        return processType + code + date;
    }
}
